package br.unicamp.ic.inf300.arena.persistencia.dao.impl; 

import java.sql.SQLException;
import java.util.Collection;

import org.apache.log4j.Logger;

import junit.framework.TestCase;
import br.unicamp.ic.inf300.arena.modelo.vendas.Bilhete;
import br.unicamp.ic.inf300.arena.persistencia.dao.IBilheteDAO;
import br.unicamp.ic.inf300.framework.persistencia.DAOFactory;

public class BilheteDAOHsqlTest extends TestCase {
	private static final String PERSISTENCIA_PROPERTIES = "br/unicamp/ic/inf300/persistencia.properties";
	
	private static Logger _logger = Logger.getLogger(BilheteDAOHsqlTest.class
			.getName());

	private IBilheteDAO daoBilhete = null;

	protected void setUp() throws Exception {
		super.setUp();
		DAOFactory.getInstance(PERSISTENCIA_PROPERTIES);
		daoBilhete = (IBilheteDAO) DAOFactory.getImpl(IBilheteDAO.class);
	}

	public void testObterBilhetes() {
		try {
			_logger.debug("\n testObterBilhetes() \n\n" );

			Collection<Bilhete> bilhetes = daoBilhete.obterBilhetes(01L);
			System.out.println("\t Bilhetes: " + bilhetes);
			assertNotNull(bilhetes);
		}
		catch (SQLException sqlErr) {
			sqlErr.printStackTrace();
			System.err.println( sqlErr.getMessage() );
			assertFalse(true);
		}
		catch (Exception err) {
			err.printStackTrace();
			System.err.println( err.getMessage() );
			assertFalse(true);
		}
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		daoBilhete = null;
	}	
}